import Vue from 'vue'
import dayjs from 'dayjs'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
// 引入自定义指令
import * as directive from '@/directive'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import i18n from '@/lang'

Vue.use(ElementUI, {
  i18n: (k, v) => i18n.t(k, v)
})

import '@/icons' // icon
import '@/permission' // permission control
// 导入自己写的组件全局注册
import Mycomponents from '@/components'
import mixin from '@/mixin'
import echarts from '@/utils/eachers'
Vue.use(echarts)
Vue.mixin(mixin)
Vue.prototype.$formap = (time) => {
  return dayjs(time).format('YYYY, MM, DD, HH, mm, ss')
}
Vue.use(Mycomponents)
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
Vue.use(ElementUI)
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false
// 全局自定义指令(使用循环对象批量注册)
Object.keys(directive).forEach((key) => {
  Vue.directive(key, directive[key])
})
// Vue.directive('border', directive.border)
// Vue.directive('imgError', directive.imgError)

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
